/**
* Oxide
*
* Copyright (c) 2011 Dinosaur Kick Pty Ltd, All rights reserved.
*
* This source code is made available under the "Modified BSD" licensing arrangement.
* See license.txt for details.
*/
// ----------------------------------------------------------------------------
#include <string>
#include <list>
#include "message.hpp"
// ----------------------------------------------------------------------------
#ifndef O2_PARSE_MESSAGE_LIST_INC
#define O2_PARSE_MESSAGE_LIST_INC
namespace o2 {
namespace parse {
// ----------------------------------------------------------------------------

template <typename StringT, typename ContainerT = std::list<basic_message<StringT> > >
class basic_message_list
	: public ContainerT
{
	public:
		typedef basic_message<StringT> message_type;
		typedef typename message_type::string_type string_type;
		typedef ContainerT container_type;

		basic_message_list(void)
			: m_level(ML_NONE)
			{ }

		basic_message_list(const basic_message_list& ml)
			: container_type(ml)
			, m_level(ml.m_level)
			{ }
		
		void push_back(const message_type& m)
		{
			if (m.level > m_level)
			{
				m_level = m.level;
			}
			container_type::push_back(m);
		}

		message_level level(void) const
			{ return m_level; }

	private:
		message_level m_level;
};

// ----------------------------------------------------------------------------

typedef basic_message_list<std::string> message_list;
typedef basic_message_list<std::wstring> wmessage_list;

// ----------------------------------------------------------------------------
} // namespace parse
} // namespace o2
#endif // O2_PARSE_MESSAGE_LIST_INC
// ----------------------------------------------------------------------------
